//
//  ActionVerifyVC.swift
//  zhonglb_iOS
//
//  Created by Rowling on 2021/9/27.
//

import UIKit

class ActionVerifyVC: ZMViewController {

    var complete : ((_ success : Bool)->())?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        var img = UIImage(named: "img_1")
        if LoginService.shared.verifImg.count > 1 {
            img = LoginService.shared.verifImg[getArc4random(LoginService.shared.verifImg.count)] //ZMAppShareData.share.verifImg[getArc4random(ZMAppShareData.share.verifImg.count - 1)]
        } else if LoginService.shared.verifImg.count == 1 {
            img = LoginService.shared.verifImg.first
        }
        VerifyView.show(VerifyType.puzzle, self.view, template: img) {[unowned self] (isSuccess) in
            if isSuccess {
                guard let complete = self.complete else {return}
                complete(isSuccess)
                if isSuccess {
                    self.dismiss(animated: true, completion: nil)
                }
            }
        }
    }
    
    func getArc4random(_ max: Int) -> Int {
        return Int(arc4random()) % max
    }
}
